<include file="Public/header" /> 

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4>会员信息</h4>
		<form class="form-horizontal" id="myform">
			<div class="form-group">
				<label for="mobile" class="col-sm-2 control-label">手机号码</label>
				<div class="col-sm-5">
					<p class="form-control-static text-info"><{$user_info['mobile']}></p>
				</div>
			</div>

			<div class="form-group">
				<label for="createtime" class="col-sm-2 control-label">注册时间</label>
				<div class="col-sm-5">
					<p class="form-control-static text-info">
						<{$user_info['createtime']|date='Y-m-d H:i:s',###}>
					</p>
				</div>
			</div>

			<div class="form-group">
				<label for="password" class="col-sm-2  control-label">新密码</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="password" id="password" placeholder="新密码">
				</div>
			</div>

			<div class="form-group">
				<label for="username" class="col-sm-2 control-label">昵称</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="username" id="username" placeholder="新昵称" value="<{$user_info['username']}>" >
					<p class="form-control-static text-info"><{$user_info['username']}></p>
				</div>
			</div>

			<div class="form-group">
				<label for="weixin" class="col-sm-2 control-label">微信号</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="weixin" id="weixin" value="<{$user_info['weixin']}>" placeholder="新微信号" >
					<p class="form-control-static text-info"><{$user_info['weixin']}></p>
				</div>
			</div>
			
			<div class="form-group">
				<label for="level" class="col-sm-2 control-label">会员等级</label>
				<div class="col-sm-5">
					<select id="level" name="level" class="form-control" defaultValue="<{$user_info['level']}>"  >
						<option value="0" level="0">非会员</option>

						<foreach name="level_list" key="key" item="row" >
							<option value="<{$key}>" <?php if ($key == $user_info['level']) { echo 'selected="selected"'; } ?> ><{$row['level_name']}></option>				
						</foreach>

					</select>
					<p class="form-control-static text-info">

					<if condition="$user_info['level']">
					<{$level_list[$user_info['level']]['level_name']}>			
					</if>
					·
					<if condition="$user_info['valid_time']">
					<{$user_info['valid_time']|date='Y-m-d H:i:s',###}>					
					</if>

					</p>
					<div id="valid_time_input" class="form-group form-group-sm" <if condition="$user_info['valid_time'] eq 0">style="display: none;" </if>>
						<label for="valid_time" class="col-xs-3 control-label">会员有效期</label>
						<div class="col-xs-9">
						<input type="text" class="form-control laydate-icon" name="valid_time" id="valid_time" value="<?php echo date("Y-m-d h:i:s")?>"placeholder="会员有效期" onclick="laydate({istime:true, format:'YYYY-MM-DD hh:mm:ss',min:laydate.now()})" >
						</div>
					</div>

					<p class="form-control-static text-warning bg-warning" id="valid_time_forever" <if condition="$user_info['valid_time'] neq 0 or $user_info['level'] eq 0">style="display: none;" </if>>
					&nbsp;·该等级会员终身有效
					</p>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">总代理</label>
				<div class="radio col-sm-5">
					<label <if condition="$user_info['super_agent'] eq 0">style="color:#3c763d;"</if> >
						<input type="radio" name="super_agent" id="super_agent0" value="0" <if condition="$user_info['super_agent'] eq 0">checked</if> />
					   	否
					</label>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<label <if condition="$user_info['super_agent'] eq 1">style="color:#3c763d;"</if> >
						<input type="radio" name="super_agent" id="super_agent1" value="1" <if condition="$user_info['super_agent'] eq 1">checked</if> />
					   	是
					</label>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">会员锁定</label>
				<div class="radio col-sm-5">
					<label <if condition="$user_info['status'] eq 0">style="color:#3c763d;"</if> >
						<input type="radio" name="status" id="status0" value="0" <if condition="$user_info['status'] eq 0">checked</if> />
					   	无锁
					</label>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<label <if condition="$user_info['status'] eq 1">style="color:#3c763d;"</if> >
						<input type="radio" name="status" id="status1" value="1" <if condition="$user_info['status'] eq 1">checked</if> />
					   	锁定
					</label>
				</div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="uid" value="<{$user_info['id']}>" />
					<button type="submit" class="btn btn-default col-sm-2">保存</button>
				</div>
			</div>
		</form>
		
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script>
$(function(){
	$('#password').on('click', function(){
	    var that = this;
	    layer.tips('密码长度由6-20字符组成,留空表示不修改密码。', that, {
		    tips: [2, '#3595CC'],
		});
	});
	
	$("#myform").validate({
		rules: {
            password: {
                rangelength:[6,20]
            }
		},
		submitHandler : function(form){
			var ajaxUrl = "<{:U('Admin/User/changememberInfo')}>";

			layer.confirm('确定提交更改！', {icon: 3}, function(index) {
				$.post(ajaxUrl,$(form).serialize(),function(r){
					if (r.error == 1){
						layer.alert(r.errmsg,{icon: 2});
					}else{
						layer.alert(r.errmsg,{icon: 1},function(index){
							window.location.href = "<{:U('Admin/User/memberList',array('k'=>2,'sk'=>0))}>";
						});
					}
					return false;
				});
			});

        	return false
		}
	});

	// 监控会员等级变更状态提示 - 失去焦点事件
	$('#level').change(function(event) {
			$(this).parent().addClass('has-warning');

			if (level_list_validate[$(this).val()])
			{	
				if (level_list_validate[$(this).val()] != 0)
				{
					$('#valid_time_input').slideDown();
					$('#valid_time_forever').hide();
				}
				else
				{
					$('#valid_time_input').slideUp();
					$('#valid_time_forever').show();
					$('input[name="valid_time"]').val('0');
				}
			}
			else
			{
				$('#valid_time_input').slideUp();
				$('#valid_time_forever').hide();
				$('input[name="valid_time"]').val('0');

			}
	});

	// 会员等级
	var level_list_validate = new Array();

	<?php foreach ($level_list as $key => $row): ?>
	level_list_validate[<{$key}>]="<{$row['valid_time']}>";
	<?php endforeach ?>
});
</script>

<include file="Public/footer" /> 